import { axios } from '@/utils/request'

const api = {
  attachment: '/attachments'
}

/**
 * @param file
 * @param isWechatMaterial 是否微信素材; 1:是 2:否
 * @returns {AxiosPromise}
 */
export function uploadAttachment (file, isWechatMaterial = 2) {
  const formData = new FormData()
  formData.append('attachment', file)
  formData.append('is_wechat_material', isWechatMaterial)

  return axios({
    url: api.attachment,
    method: 'post',
    data: formData
  })
}

export function getAsyncExportTaskList (params) {
  return axios({
    url: api.attachment + '/download-async-export-task',
    method: 'get',
    params
  })
}

export function downloadAsyncExportTask (id) {
  return axios({
    url: api.attachment + '/download-async-export-task/' + id,
    method: 'get'
  })
}
